//
//  IntExtensions.swift
//  FoundationCustom
//
//  Created by ZhouJiatao on 2019/9/5.
//  Copyright © 2019 Unknow. All rights reserved.
//

import Foundation

public extension Int {
    
    /// 输出指定位数的字符串，不够位数时，前面补零
    ///
    /// - Parameter digit: 字符串位数
    public func zerofillStr(digit: Int) -> String {
        
        var result = String(self)
        let gap = digit - result.count
        
        if gap > 0 {
            let fill = String(repeating: "0", count: gap)
            result = fill.appending(result)
        }
        return result
    }
}
